/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.common.f;

import java.security.KeyFactory;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public class a {
    private RSAPublicKey a;
    private final int b = 256;
    private final int c = 16;
    private static final byte[] d = { -42, 86, 61, -4, -126, 120, 88, -78, -91, -38, 90, -57, -35, -80, -16, -75 };
    private final IvParameterSpec e = new IvParameterSpec(d);

    public boolean a(byte[] paramArrayOfByte) {
        KeyFactory localKeyFactory = KeyFactory.getInstance("RSA");
        RSAPublicKey localRSAPublicKey = (RSAPublicKey) localKeyFactory.generatePublic(new X509EncodedKeySpec(
                paramArrayOfByte));
        return a(localRSAPublicKey);
    }

    public boolean a(RSAPublicKey paramRSAPublicKey) {
        this.a = paramRSAPublicKey;
        return (this.a != null);
    }

    public byte[] b(byte[] paramArrayOfByte) {
        byte[] arrayOfByte1 = new byte[0];
        int i = 0;
        super.getClass();
        if (paramArrayOfByte.length < 256 - 11) {
            arrayOfByte1 = c(paramArrayOfByte);
        }
        else {
            i = (byte) (i | 0x80);
            arrayOfByte2 = a();
            byte[] arrayOfByte3 = c(arrayOfByte2);
            byte[] arrayOfByte4 = a(arrayOfByte2, paramArrayOfByte);
            int j = (byte) (arrayOfByte3.length >> 5);
            arrayOfByte1 = new byte[1 + arrayOfByte3.length + arrayOfByte4.length];
            arrayOfByte1[0] = j;
            System.arraycopy(arrayOfByte3, 0, arrayOfByte1, 1, arrayOfByte3.length);
            System.arraycopy(arrayOfByte4, 0, arrayOfByte1, 1 + arrayOfByte3.length, arrayOfByte4.length);
        }
        byte[] arrayOfByte2 = new byte[1 + arrayOfByte1.length];
        arrayOfByte2[0] = i;
        System.arraycopy(arrayOfByte1, 0, arrayOfByte2, 1, arrayOfByte1.length);
        return arrayOfByte2;
    }

    private byte[] c(byte[] paramArrayOfByte) {
        Cipher localCipher = Cipher.getInstance("RSA/ECB/PKCS1PADDING");
        localCipher.init(1, this.a);
        byte[] arrayOfByte = localCipher.doFinal(paramArrayOfByte);
        return arrayOfByte;
    }

    private byte[] a() {
        super.getClass();
        return a(16);
    }

    private byte[] a(int paramInt) {
        KeyGenerator localKeyGenerator = KeyGenerator.getInstance("AES");
        localKeyGenerator.init(paramInt << 3);
        byte[] arrayOfByte = localKeyGenerator.generateKey().getEncoded();
        return arrayOfByte;
    }

    private byte[] a(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2) {
        SecretKeySpec localSecretKeySpec = new SecretKeySpec(paramArrayOfByte1, "AES");
        Cipher localCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        localCipher.init(1, localSecretKeySpec, this.e);
        byte[] arrayOfByte = localCipher.doFinal(paramArrayOfByte2);
        return arrayOfByte;
    }
}